
package com.servicelivedb;

import java.util.Date;
import java.util.List;
import com.servicelivedb.data.Block;
import com.servicelivedb.data.Door;
import com.servicelivedb.data.output.AllVendorOrderSummaryByRangeRtnType;
import com.servicelivedb.data.output.AllVendorOrderSummaryRtnType;
import com.servicelivedb.data.output.CustomerOrderSummaryByRangeRtnType;
import com.servicelivedb.data.output.CustomerOrderSummaryRtnType;
import com.servicelivedb.data.output.GetAllProjectServiceVendorsRtnType;
import com.servicelivedb.data.output.GetAllVendorsForProjectRtnType;
import com.servicelivedb.data.output.GetLoginStatusRtnType;
import com.servicelivedb.data.output.GetProjectBYNameRtnType;
import com.servicelivedb.data.output.GetProjectServiceVendorsRtnType;
import com.servicelivedb.data.output.GetProjectServicesRtnType;
import com.servicelivedb.data.output.GetTodaysVendorOrdersRtnType;
import com.servicelivedb.data.output.GetUniqueProjectsRtnType;
import com.servicelivedb.data.output.GetVendorItemTypeRtnType;
import com.servicelivedb.data.output.GetVendorOrderHistoryRtnType;
import com.servicelivedb.data.output.ValidateActivationCodeRtnType;
import com.servicelivedb.data.output.VendorOrderDetailsByRangeRtnType;
import com.servicelivedb.data.output.VendorOrderSummaryByRangeRtnType;
import com.servicelivedb.data.output.VendorOrderSummaryRtnType;
import com.wavemaker.json.type.TypeDefinition;
import com.wavemaker.runtime.data.DataServiceManager;
import com.wavemaker.runtime.data.DataServiceManagerAccess;
import com.wavemaker.runtime.data.TaskManager;
import com.wavemaker.runtime.service.LiveDataService;
import com.wavemaker.runtime.service.PagingOptions;
import com.wavemaker.runtime.service.PropertyOptions;
import com.wavemaker.runtime.service.TypedServiceReturn;


/**
 *  Operations for service "serviceliveDB"
 *  02/04/2014 10:43:30
 * 
 */
@SuppressWarnings("unchecked")
public class ServiceliveDB
    implements DataServiceManagerAccess, LiveDataService
{

    private DataServiceManager dsMgr;
    private TaskManager taskMgr;

    public Integer accDetailsUpdate(String name, String password, Integer doorId, Integer blockId, String primaryPhone, String secondaryPhone, Integer customerId, PagingOptions pagingOptions) {
        List<Integer> rtn = ((List<Integer> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.accDetailsUpdateQueryName), name, password, doorId, blockId, primaryPhone, secondaryPhone, customerId, pagingOptions));
        if (rtn.isEmpty()) {
            return null;
        } else {
            return rtn.get(0);
        }
    }

    public List<AllVendorOrderSummaryRtnType> allVendorOrderSummary(PagingOptions pagingOptions) {
        return ((List<AllVendorOrderSummaryRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.allVendorOrderSummaryQueryName), pagingOptions));
    }

    public List<AllVendorOrderSummaryByRangeRtnType> allVendorOrderSummaryByRange(Date startDate, Date endDate, PagingOptions pagingOptions) {
        return ((List<AllVendorOrderSummaryByRangeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.allVendorOrderSummaryByRangeQueryName), startDate, endDate, pagingOptions));
    }

    public Integer clearCustomerOrderHistoryDetails(Boolean status, Integer customerId, PagingOptions pagingOptions) {
        List<Integer> rtn = ((List<Integer> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.clearCustomerOrderHistoryDetailsQueryName), status, customerId, pagingOptions));
        if (rtn.isEmpty()) {
            return null;
        } else {
            return rtn.get(0);
        }
    }

    public List<CustomerOrderSummaryRtnType> customerOrderSummary(Integer customerId, PagingOptions pagingOptions) {
        return ((List<CustomerOrderSummaryRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.customerOrderSummaryQueryName), customerId, pagingOptions));
    }

    public List<CustomerOrderSummaryByRangeRtnType> customerOrderSummaryByRange(Date startDate, Date endDate, Integer customerId, PagingOptions pagingOptions) {
        return ((List<CustomerOrderSummaryByRangeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.customerOrderSummaryByRangeQueryName), startDate, endDate, customerId, pagingOptions));
    }

    public List<GetAllProjectServiceVendorsRtnType> getAllProjectServiceVendors(Boolean active, Integer projectId, PagingOptions pagingOptions) {
        return ((List<GetAllProjectServiceVendorsRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getAllProjectServiceVendorsQueryName), active, projectId, pagingOptions));
    }

    public List<GetAllVendorsForProjectRtnType> getAllVendorsForProject(Boolean active, Integer projectId, PagingOptions pagingOptions) {
        return ((List<GetAllVendorsForProjectRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getAllVendorsForProjectQueryName), active, projectId, pagingOptions));
    }

    public List<Block> getBlocksByProject(Integer projectId, PagingOptions pagingOptions) {
        return ((List<Block> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getBlocksByProjectQueryName), projectId, pagingOptions));
    }

    public List<Door> getDoorsByProjectBlock(Integer blockId, PagingOptions pagingOptions) {
        return ((List<Door> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getDoorsByProjectBlockQueryName), blockId, pagingOptions));
    }

    public List<GetLoginStatusRtnType> getLoginStatus(String username, PagingOptions pagingOptions) {
        return ((List<GetLoginStatusRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getLoginStatusQueryName), username, pagingOptions));
    }

    public List<GetProjectBYNameRtnType> getProjectBYName(Boolean activeFlag, String projectName, PagingOptions pagingOptions) {
        return ((List<GetProjectBYNameRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getProjectBYNameQueryName), activeFlag, projectName, pagingOptions));
    }

    public List<GetProjectServiceVendorsRtnType> getProjectServiceVendors(Boolean active, Integer projectId, Integer serviceId, PagingOptions pagingOptions) {
        return ((List<GetProjectServiceVendorsRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getProjectServiceVendorsQueryName), active, projectId, serviceId, pagingOptions));
    }

    public List<GetProjectServicesRtnType> getProjectServices(Boolean active, Integer projectId, PagingOptions pagingOptions) {
        return ((List<GetProjectServicesRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getProjectServicesQueryName), active, projectId, pagingOptions));
    }

    public List<GetTodaysVendorOrdersRtnType> getTodaysVendorOrders(Integer vendorId, String statusNew, String statusPartly, PagingOptions pagingOptions) {
        return ((List<GetTodaysVendorOrdersRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getTodaysVendorOrdersQueryName), vendorId, statusNew, statusPartly, pagingOptions));
    }

    public List<GetUniqueProjectsRtnType> getUniqueProjects(Boolean activeFlag, PagingOptions pagingOptions) {
        return ((List<GetUniqueProjectsRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getUniqueProjectsQueryName), activeFlag, pagingOptions));
    }

    public com.servicelivedb.data.UserRole getUserRoleById(Integer id, PagingOptions pagingOptions) {
        List<com.servicelivedb.data.UserRole> rtn = ((List<com.servicelivedb.data.UserRole> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getUserRoleByIdQueryName), id, pagingOptions));
        if (rtn.isEmpty()) {
            return null;
        } else {
            return rtn.get(0);
        }
    }

    public List<GetVendorItemTypeRtnType> getVendorItemType(Integer serviceId, Integer vendorId, PagingOptions pagingOptions) {
        return ((List<GetVendorItemTypeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getVendorItemTypeQueryName), serviceId, vendorId, pagingOptions));
    }

    public List<GetVendorOrderHistoryRtnType> getVendorOrderHistory(String statusNew, String statusPartly, Integer vendorId, Date prevDate, PagingOptions pagingOptions) {
        return ((List<GetVendorOrderHistoryRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.getVendorOrderHistoryQueryName), statusNew, statusPartly, vendorId, prevDate, pagingOptions));
    }

    public Integer updateOrderItemStatus(String status, Integer orderItemId, PagingOptions pagingOptions) {
        List<Integer> rtn = ((List<Integer> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.updateOrderItemStatusQueryName), status, orderItemId, pagingOptions));
        if (rtn.isEmpty()) {
            return null;
        } else {
            return rtn.get(0);
        }
    }

    public Integer updateOrderStatus(String status, Integer orderId, String vendor_comment, PagingOptions pagingOptions) {
        List<Integer> rtn = ((List<Integer> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.updateOrderStatusQueryName), status, orderId, vendor_comment, pagingOptions));
        if (rtn.isEmpty()) {
            return null;
        } else {
            return rtn.get(0);
        }
    }

    public List<ValidateActivationCodeRtnType> validateActivationCode(Integer projectId, Boolean activeFlag, PagingOptions pagingOptions) {
        return ((List<ValidateActivationCodeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.validateActivationCodeQueryName), projectId, activeFlag, pagingOptions));
    }

    public List<VendorOrderDetailsByRangeRtnType> vendorOrderDetailsByRange(Date startDate, Date endDate, Integer customerId, PagingOptions pagingOptions) {
        return ((List<VendorOrderDetailsByRangeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.vendorOrderDetailsByRangeQueryName), startDate, endDate, customerId, pagingOptions));
    }

    public List<VendorOrderSummaryRtnType> vendorOrderSummary(Integer vendorId, PagingOptions pagingOptions) {
        return ((List<VendorOrderSummaryRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.vendorOrderSummaryQueryName), vendorId, pagingOptions));
    }

    public List<VendorOrderSummaryByRangeRtnType> vendorOrderSummaryByRange(Integer vendorId, Date startDate, Date endDate, PagingOptions pagingOptions) {
        return ((List<VendorOrderSummaryByRangeRtnType> ) dsMgr.invoke(taskMgr.getQueryTask(), (ServiceliveDBConstants.vendorOrderSummaryByRangeQueryName), vendorId, startDate, endDate, pagingOptions));
    }

    public Object insert(Object o) {
        return dsMgr.invoke(taskMgr.getInsertTask(), o);
    }

    public TypedServiceReturn read(TypeDefinition rootType, Object o, PropertyOptions propertyOptions, PagingOptions pagingOptions) {
        return ((TypedServiceReturn) dsMgr.invoke(taskMgr.getReadTask(), rootType, o, propertyOptions, pagingOptions));
    }

    public Object update(Object o) {
        return dsMgr.invoke(taskMgr.getUpdateTask(), o);
    }

    public void delete(Object o) {
        dsMgr.invoke(taskMgr.getDeleteTask(), o);
    }

    public void begin() {
        dsMgr.begin();
    }

    public void commit() {
        dsMgr.commit();
    }

    public void rollback() {
        dsMgr.rollback();
    }

    public DataServiceManager getDataServiceManager() {
        return dsMgr;
    }

    public void setDataServiceManager(DataServiceManager dsMgr) {
        this.dsMgr = dsMgr;
    }

    public TaskManager getTaskManager() {
        return taskMgr;
    }

    public void setTaskManager(TaskManager taskMgr) {
        this.taskMgr = taskMgr;
    }

}
